Crimson Editor is equiped with a calculator that can evaluate simple expressions.
If you want to calculate a simple expression, use Crimson Editor built-in calculator to get the answer quickly.
Following examples show how to use Crimson Editor built-in calculator.
1. Type in the expression you want to evaluate in Crimson Editor.
(The whole expression should be written in one line)
2. Press Ctrl+Enter to calculate the expression
when the caret is in the line of expression.
i.e.
3.14 * (2.43 + 0.91) <– press Ctrl+Enter when the caret is in the line of expression
= 10.487600 <– you will get the answer immediately
If you want to use the value that was evaluated in the earler step, use a special variable named $ans.
There is another built-in variable named $pi, and the value of the variable $pi is 3.1415926535.
$ans / $pi
= 3.338307
Crimson Editor supports basic mathematics functions which are very similar to those used in C math library.
sin(1.2) + atan2(3.2, 4.3)
= 1.571809
Following list shows basic mathematics functions supported by Crimson Editor.
abs,
fabs,
mod,
fmod,
ceil,
floor,
round,
min,
max,
acos,
asin,
atan,
atan2,
cos,
sin,
tan,
cosh,
sinh,
tanh,
exp,
log,
log10,
pow,
sqr,
sqrt
Date functions, those are frequently used in financial problems, are now available in Crimson Editor 3.45.
Following list shows date functions supported by Crimson Editor.
today,
yeardays,
monthdays,
date2days,
days2date,
eomday,
eomdate,
weekday,
isbizdate,
nbizdate,
pbizdate,
adddays,
addmonths,
addterms,
days360,
days365,
daysact,
daysbet,
monthsbet,
termsbet,
termfrac,
yearfrac
Mathematics Functions
| ↑ Top |
abs, fabs |
absolute value functions |
fabs(x) returns the absolute value of x, |x|. |
|
mod, fmod |
remainder functions |
fmod(x, y) returns the remainder f of the division of x by y, where f has the same sign as x, such that x=iy+f for some integer i, and |f| < |y|. |
|
ceil |
ceiling function |
ceil(x) returns the smallest integer not less than x. |
|
floor |
floor function |
floor(x) returns the largest integer not greater than x. |
|
round |
round function |
round(x) rounds its argument to the nearest integral value. |
|
min |
min(x, y) returns the minimum of a pair of values |
|
max |
max(x, y) returns the maximum of a pair of values |
|
acos |
arccosine function |
acos(x) returns the arccosine of x in the range 0 to pi. |
|
asin |
arcsine function |
asin(x) returns the arcsine of x in the range -pi/2 to pi/2. |
|
atan |
arctangent function |
atan(x) returns the arctangent of x in the range -pi/2 to pi/2. |
|
atan2 |
arctangent-and-quadrant function |
atan2(y, x) returns the arctangent of y/x, in the range -pi to pi, using the signs of both arguments to determine the quadrant of the return value. |
|
cos |
cosine function |
cos(x) returns the cosine of x (x specified in radians). |
|
sin |
sine function |
sin(x) returns the sine of x (x specified in radians). |
|
tan |
tangent function |
tan(x) returns the tangent of x (x specified in radians). |
|
cosh |
hyperbolic cosine function |
cosh(x) returns the hyperbolic cosine of its argument. |
|
sinh |
hyperbolic sine function |
sinh(x) returns the hyperbolic sine of its argument. |
|
tanh |
hyperbolic tangent function |
tanh(x) returns the hyperbolic tangent of its argument. |
|
exp |
exponential function |
exp(x) returns e^x. |
|
log |
natural logarithm function |
log(x) returns the natural logarithm of x. The value of x must be greater than zero. |
|
log10 |
common logarithm function |
log10(x) returns the logarithm base ten of x. The value of x must be greater than zero. |
|
pow |
power function |
pow(x, y) returns x^y. If x is negative, y must be an integer value. |
|
sqr |
square function |
sqr(x) returns x*x. |
|
sqrt |
square root function |
sqrt(x) returns the non-negative square root of x. The value of x must not be less than zero. |
today |
current date |
today() returns the current date as a number. |
i.g. 20020807 (Aug. 07, 2002) |
|
yeardays |
number of days in a year |
yeardays(year) returns the actual number of days in the given year. |
|
monthdays |
number of days in a month |
monthdays(year, month) returns the actual number of days in the given month. |
|
date2days |
date to serial date number conversion |
date2days(date) returns the number of days to the given date since the Epoch. |
|
days2date |
serial date number to date conversion |
days2date(days) returns the date calculated from the given number of days since the Epoch. |
|
eomday |
last day of month |
eomday(year, month) returns the last day of the month for the given year and month. |
|
eomdate |
last date of month |
eomdate(year, month) returns the last date of the month for the given year and month. |
|
weekday |
day of the week |
weekday(date) returns the day of the week in numeric form. |
weekday: 0 = Sun, 1 = Mon, 2 = Tue, 3 = Wed, 4 = Thu, 5 = Fri, 6 = Sat |
|
isbizdate |
true for date that is business day |
isbizday(date) returns 1 if date is a business day and 0 otherwise. |
|
nbizdate |
next business day |
nbizdate(date) returns the date of the next business day from the reference date. |
|
pbizdate |
previous business day |
pbizdate(date) returns the date of the previous business day from the reference date. |
|
adddays |
date added by given days |
adddays(date, days) returns the reference date added by given days. |
|
addmonths |
date added by given months |
addmonths(date, months, end_month) returns the reference date added by given months. |
end_month: 0 = actual, 1 = end month |
|
addterms |
date added by given terms |
addterms(date, terms, frequency, end_month) returns the reference date added by given terms. |
frequency: 1 = annual, 2 = semiannual, 4 = quarterly, 6 = bimonthly,
12 = monthly
end_month: 0 = actual, 1 = end month
|
|
days360 |
days between dates based on 360-day year |
days360(start_date, end_date, european) returns the number of days between start_date and end_date based on a 360-day year. |
european: 0 = american, 1 = european |
|
days365 |
days between dates based on 365-day year |
days365(start_date, end_date) returns the number of days between start_date and end_date based on a 365-day year. |
|
daysact |
actual number of days between dates |
daysact(start_date, end_date) returns the actual number of days between two dates. |
|
daysbet |
days between dates for any day-count basis |
daysbet(start_date, end_date, basis) returns the number of days between start_date and end_date using the given day-count basis. |
basis: 0 = actual/actual, 1 = actual/360, 2 = actual/365, 3 = 30/360,
4 = 30E/360, 5 = NL/365
|
|
monthsbet |
months between dates |
monthsbet(start_date, end_date) returns the number of months between start_date and end_date. |
|
termsbet |
terms between dates |
termsbet(start_date, end_date, frequency) returns the number of terms between start_date and end_date. |
frequency: 1 = annual, 2 = semiannual, 4 = quarterly, 6 = bimonthly,
12 = monthly
|
|
termfrac |
fraction of term between dates |
termfrac(start_date, end_date, frequency, basis, end_month) returns a fraction based on the number of days between start_date and end_date using the given day-count basis. |
frequency: 1 = annual, 2 = semiannual, 4 = quarterly, 6 = bimonthly,
12 = monthly
basis: 0 = actual/actual, 1 = actual/360, 2 = actual/365, 3 = 30/360,
4 = 30E/360, 5 = NL/365
end_month: 0 = actual, 1 = end month
|
|
yearfrac |
fraction of year between dates |
yearfrac(start_date, end_date, basis, end_month) returns a fraction based on the number of days between start_date and end_date using the given day-count basis. |
basis: 0 = actual/actual, 1 = actual/360, 2 = actual/365, 3 = 30/360,
4 = 30E/360, 5 = NL/365
end_month: 0 = actual, 1 = end month
|
|